﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Huyn.QRCode;
using System.Globalization;
using FinApp.DataProviders;

namespace FinApp.Views {
    public partial class QRViewerPage : PhoneApplicationPage {
        public QRViewerPage() {
            InitializeComponent();
        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) {
            base.OnNavigatedTo(e);
            IDictionary<string, string> parameters = this.NavigationContext.QueryString;
            string password = parameters["Password"];
            string salt = parameters["Salt"];
            string token = parameters["Token"];
            string checkField = parameters["CheckField"];
            string commerceId = parameters["CommerceId"];

            var generator = new QRCodeGenerator();
            this.qrCodeImage.Source = generator.Generate("{ \"checkField\": \"" + checkField + "\", \"commerceId\": \"" + commerceId + "\", \"Token\": " + ChryptoProvider.Instance.EncryptString(token, password, salt) + " }");

        }
    }
}